package org.ucas.faker.web.dao.graph;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.ucas.faker.web.utils.graph.InstituteCount;
import org.ucas.faker.web.utils.graph.Inventor;
import org.ucas.faker.web.utils.graph.TechBranchEffect;
import org.ucas.faker.web.utils.graph.YearCount;

import java.util.HashMap;
import java.util.List;

@Repository
@Mapper
public interface Graph8Mapper {
	List<HashMap> GetTop20ByProvDesc();
	
	List<HashMap> GetTop10ByLegalState();
	
	List<HashMap> GetKeyTechLawStatus();
	
	List<HashMap> GetKeyTechLawStatusGroupByStatus();
	
	List<HashMap> GetTop10KeyTechApply();
	
	List<HashMap> GetTop10KeyTechApplyYearTrend();
	
	List<HashMap> GetTop10KeyTechApplyHomeTrend();
	
	@Select("select applican_province,count(*) from patent "+
	"where applican_province in ('美国','韩国','TW','日本','瑞士','西班牙','德国','法国','英国','意大利',"+
	"'新加坡','芬兰','瑞典','澳大利亚','台湾','丹麦','印度','Mumbai','荷兰','以色列')"+
	"group by applican_province "+
	"order by count(applican_province) desc, applican_province asc "+
	"limit 10")
	List<String> GetTop10KeyTechApplyProv();
	
	
	@Select("select applican_province,count(*) from patent "+
	"where applican_province not in ('美国','韩国','TW','日本','瑞士','西班牙','德国','法国','英国','意大利',"+
	"'新加坡','芬兰','瑞典','澳大利亚','台湾','丹麦','印度','Mumbai','荷兰','以色列')"+
	"group by applican_province "+
	"order by count(applican_province) desc, applican_province asc "+
	"limit 10")
	List<String> GetTop10KeyTechApplyProvHome();
	
	List<YearCount> GetApplyYear();
	
	List<YearCount> GetAuthorizeYear();	
	
	@Select("select ap,count(*) as appcount "+
	"from patent "+
	"group by ap "+
	"order by count(*) desc "+
	"limit 20")
	List<InstituteCount> GetTop20Institute();
	
	List<HashMap> GetTop10InstApplyTrend();
	
	@Select("select ap from patent group by ap order by count(*) desc limit 10")
	List<String> GetTop10InstApply();
	
	@Select("select in,ap,application_year as year from patent")
	List<Inventor> GetInventorsWithYears();
	
	@Select("select tech_branch,tech_effect from feature")
	List<TechBranchEffect> GetBranchAndEffect();
}